<!DOCTYPE html>
<html>

<head>
    <meta charset=utf-8>
    <meta name=viewport content="width=device-width,initial-scale=1">
    <title>rc</title>
    <link href=./static/css/app.css rel=stylesheet>
    <link rel="stylesheet" href="../common/loading.css">
</head>
<script>
    window.ClientApi = null;

    var CustomEvents = function () {
        this.event = {
            ready: [],
        };
        this.status = {
            ready: false,
        };
        this.config = {
            winConfig: {},
            projectInfo: {},
            userInfo: {},
            projectList: [],
        };
    };
    CustomEvents.prototype.ready = function () {
        this.status.ready = true;
        for (let i = 0; i < this.event.ready.length; i++) {
            const element = this.event.ready[i];
            element();
        };
        this.event.ready = [];
    };
    CustomEvents.prototype.onReady = function (event) {
        if (this.status.ready) {
            event();
        } else {
            this.event.ready.push(event);
        };
    };
    var _$Events = new CustomEvents();
    const { remote, ipcRenderer } = require('electron');
    ipcRenderer.on('dataJsonPort', async function (event, message) {
        _$Events.config.winConfig = JSON.parse(message);
        window.ClientApi = require('../common/localDB');

        // 项目列表
        var projectList = await window.ClientApi.project.getProjectList();
        _$Events.config.projectList = projectList.res;

        // 预备信息
        if (!_$Events.config.winConfig.projectId) {
            _$Events.config.winConfig.projectId = projectList.res[0].projectId;
        };

        // 获取用户信息
        var userInfo = await window.ClientApi.user.getMainUser();
        _$Events.config.userInfo = userInfo.res;
        setTimeout(() => {
            var mainLoading = document.getElementById('mainLoading');
            mainLoading.style.display = 'none';
            _$Events.ready();
        }, 2000);
    });


</script>


<body oncontextmenu=doNothing()>
    <div id="mainLoading" class='loader'>
        <div class='loader_overlay'></div>
        <div class='loader_cogs'>
            <div class='loader_cogs__top'>
                <div class='top_part'></div>
                <div class='top_part'></div>
                <div class='top_part'></div>
                <div class='top_hole'></div>
            </div>
            <div class='loader_cogs__left'>
                <div class='left_part'></div>
                <div class='left_part'></div>
                <div class='left_part'></div>
                <div class='left_hole'></div>
            </div>
            <div class='loader_cogs__bottom'>
                <div class='bottom_part'></div>
                <div class='bottom_part'></div>
                <div class='bottom_part'></div>
                <div class='bottom_hole'></div>
            </div>
        </div>
        <p id="loadingText">loading</p>
    </div>
    <div id=app></div>
</body>

<script>
    const customTitlebar = require('custom-electron-titlebar');
    var titlebar = new customTitlebar.Titlebar({
        backgroundColor: customTitlebar.Color.fromHex('#fff'),
        enableMnemonics: false,
    });
    titlebar.titlebar.style.left = '0px';
    titlebar.titlebar.style.width = 'auto';
    titlebar.titlebar.style.right = '0px';
    titlebar.titlebar.style.zIndex = '40';
    titlebar.container.style.top = '0px';
    titlebar.title.style.visibility = 'hidden';
    titlebar.menubarContainer.style.display = 'none'
</script>

<script type=text/javascript src=./static/js/manifest.js></script>
<script type=text/javascript src=./static/js/vendor.js></script>
<script type=text/javascript src=./static/js/app.js></script>
<style>
    *:focus {
        outline: none;
    }
</style>



</html>